package com.angel.webapp;

import static org.junit.Assert.*;

import org.junit.Test;

import com.angel.email.account.AccountInformation;
import com.angel.email.account.impl.MockAccountInformation;
import com.angel.email.configuration.EmailConfiguration;
import com.angel.email.configuration.builders.EmailConfigurationBuilder;
import com.angel.email.configuration.builders.impl.google.GoogleIncomingEmailConfigurationBuilder;
import com.angel.email.connection.IncomingEmailConnection;
import com.angel.webapp.file.FileInformation;

/**
 *
 * @author William
 *
 */
public class DownloadEmailMessageTestCase {

	@Test
	public void testDownloadEmailAttachment(){
		AccountInformation accountInfo = new MockAccountInformation("guillesalazar@gmail.com", "42416467");
		EmailConfigurationBuilder ecb = new EmailConfigurationBuilder(Boolean.FALSE);
		ecb.setIncomingConfigurationBuilder(new GoogleIncomingEmailConfigurationBuilder(accountInfo));
		EmailConfiguration emailConfiguration = ecb.buildEmailConfiguration();
		IncomingEmailConnection emailConnection = emailConfiguration.connectToIncomingEmail();
		FileInformation fileInformation = emailConnection.getAttachmentForMessage("INBOX", 8);
		assertTrue("File information has content: ", fileInformation.hasContent());
		emailConnection.closeConnection();
	}
}
